package com.huawei;

import java.util.Random;
import java.util.Scanner;

public class yy {
    public static void main(String[] args) {
        int person, computer,win=0,lose=0;
        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        System.out.println("石头剪刀布小游戏");
        System.out.println("请你选择出拳数字");
        System.out.println("开始咯");
        for (int i = 1; i <= 5; i++) {
            System.out.println("第"+i+"局");
            System.out.println(" 1为 石头 \n 2为 剪刀 \n 3为 布");
            person = sc.nextInt();
            switch (person) {
                case 1:
                    System.out.println("玩家出拳：石头");
                    break;

                case 2:
                    System.out.println("玩家出拳：剪刀");
                    break;

                case 3:
                    System.out.println("玩家出拳：布  ");
                    break;
            }
            System.out.println("轮到电脑出拳。");
            computer = r.nextInt(3) + 1;//表示电脑出拳随机数为1,2,3
            switch (computer) {
                case 1:
                    System.out.println("电脑出拳：石头");
                    break;

                case 2:
                    System.out.println("电脑出拳：剪刀");
                    break;

                case 3:
                    System.out.println("电脑出拳：布  ");
                    break;
            }
            if (person == computer)
                System.out.println("玩家与电脑出拳相同！ 这局平手！！");
            else if (person == 1 && computer == 2){
                System.out.println("这局你赢啦！你获得一分 ");win++;}
            else if (person == 1 && computer == 3){
                System.out.println("可惜了，电脑赢下这局，你得一分");lose++;}
            else if (person == 2 && computer == 1){
                System.out.println("可惜了，电脑赢下这局，电脑得一分");lose++;}
            else if (person == 2 && computer == 3){
                System.out.println("这局你赢啦！你获得一分 ");win++;}
            else if (person == 3 && computer == 1){
                System.out.println("这局你赢啦！你获得一分 ");win++;}
            else if (person == 3 && computer == 2){
                System.out.println("可惜了，电脑赢下这局，电脑得一分 ");lose++;}
            System.out.println("目前比分"+win+" :"+lose);
        }
        if (win>lose){
            System.out.println("你赢啦！真厉害！");
        }
        else if (win<lose){
            System.out.println("你输了，不要气馁，再来");
        }
        else{
            System.out.println("可以啊，你和电脑打成了平手");
        }
    }
}
